<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Rep\JobTypeRep;
use Illuminate\Http\Request;

class JobType extends Controller
{
    //工种管理
    protected $rep;

    public function __construct(Request $request)
    {
        $this->rep = new JobTypeRep();
    }

    /**
     * 获取工种列表
     * @param Request $request
     */
    public function getJobTypeList(Request $request){
        $params = $request->all();
        $data = $this->rep->getJobTypeListRep($params);
        return re(0,$data,'success');
    }

    /**
     * 获取工种下拉框
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function getJobTypeListDropDown(Request $request){
        $params = $request->all();
        $data = $this->rep->getJobTypeListDropDownRep($params);
        return re(0,$data,'success');
    }


    /**
     * 添加工种
     * @param Request $request
     */
    public function createJobType(Request $request){
        $params = $request->all();
        $data = $this->rep->createJobTypeRep($params);
        return re($data['code'],$data['data']);
    }

    /**
     * 删除工种
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function delJobType(Request $request){
        $params = $request->all();
        $data = $this->rep->delJobTypeRep($params);
        return re($data['code']);
    }

    /**根据工种ID获取员工列表**/
    public function getUserListByJobTypeId(Request $request){
        $params = $request->all();
        $data = $this->rep->getUserListByJobTypeIdRep($params);
        return re($data['code'],$data['data']);
    }


}
